/// @tags: DivideBlock
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxn = 1e5 + 3, block = 330;

int bel[maxn], L[maxn], R[maxn];
int val[maxn], preGcd[maxn], preXor[maxn];

struct Node {
  int val, id;
  inline bool operator<(const Node &rhs) const {
    return val == rhs.val ? id < rhs.id : val < rhs.val;
  }
  inline bool operator<(int rhs) const { return val < rhs; }
} a[maxn];

int getGcd(int a, int b) { return b ? getGcd(b, a % b) : a; }

inline void build(int i) {
  preGcd[L[i]] = preXor[L[i]] = val[L[i]];
  a[L[i]].val = val[L[i]], a[L[i]].id = L[i];
  for (int j = L[i] + 1; j <= R[i]; ++j) {
    preGcd[j] = getGcd(preGcd[j - 1], val[j]);
    preXor[j] = preXor[j - 1] ^ val[j];
    a[j].val = preXor[j], a[j].id = j;
  }
  std::sort(a + L[i], a + R[i] + 1);
}

inline void init(int n) {
  const int bcnt = (n - 1) / block + 1;
  for (int i = 1; i <= bcnt; ++i) L[i] = R[i - 1] + 1, R[i] = L[i] + block - 1;
  R[bcnt] = n;
  for (int i = 1; i <= bcnt; ++i) {
    for (int j = L[i]; j <= R[i]; ++j) {
      bel[j] = i;
    }
    build(i);
  }
}

inline int main() {
  int n, q;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> val[i];
  }
  init(n);
  cin >> q;
  char opt[10];
  while (q--) {
    cin >> opt;
    switch (opt[0]) {
      case 'M': {
        int id;
        LL x;
        cin >> id >> x;
        val[++id] = x;
        build(bel[id]);
      } break;
      case 'Q': {
        LL x;
        int ans = 0;
        cin >> x;
        LL gcd = val[1], sumXor = 0;
        for (int i = 1; i <= bel[n]; ++i) {
          if (getGcd(gcd, preGcd[R[i]]) == gcd) {
            if (!(x % gcd)) {
              LL k = x / gcd ^ sumXor;
              auto p = std::lower_bound(a + L[i], a + R[i] + 1, k);
              if (p->val == k && L[i] <= p->id && p->id <= R[i]) {
                ans = p->id;
                break;
              }
            }
            gcd = getGcd(gcd, preGcd[R[i]]);
            sumXor ^= preXor[R[i]];
          } else {
            for (int j = L[i]; j <= R[i]; ++j) {
              gcd = getGcd(gcd, val[j]);
              sumXor ^= val[j];
              if (gcd * sumXor == x) {
                ans = j;
                break;
              }
            }
          }
          if (ans) break;
        }
        ans ? cout << ans - 1 << '\n' : cout << "no\n";
      } break;
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P4108 [HEOI2015] 公约数数列.in", "r", stdin);
  freopen("P4108 [HEOI2015] 公约数数列.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
